package com.firmail.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.firmail.dao.AppLogMapper;
import com.firmail.entity.AppLog;
import com.firmail.entity.ExtendedParam;

@Service
public class AppLogService {
//	@Autowired
//	AppLogMapper appLogMapper;
//	@Autowired
//	OssService ossService;

	public List<AppLog> getLogs(ExtendedParam param) {
		//List<AppLog> appLogs = appLogMapper.getLogFiles(param);
		List<AppLog> appLogs = new ArrayList<>();
		if (appLogs != null && appLogs.size() > 0) {
			StringBuffer str = new StringBuffer();
			for (AppLog appLog : appLogs) {
				str.append(",").append(appLog.getFileId());
			}
			//Map<String, String> map = ossService.getUrls(str.substring(1));
			Map<String, String> map = new HashMap<>();
			if (map != null) {
				for (int i = 0; i < appLogs.size(); i++) {
					AppLog appLog = appLogs.get(i);
					appLog.setUrl(map.get(appLog.getFileId()));
				}
			}
		}
		return appLogs;
	}
}
